home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
pas_0593.zip
/
FSIZE.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-05-30
|
3KB
|
68 lines
{─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
Msg : 163 of 187
From : BRIAN PAPE 1:2250/26.0 21 May 93 09:47
To : ALL
Subj : DOS Fsize...
────────────────────────────────────────────────────────────────────────────────
All DOS would have needed in 6.0 (unless it is there, I don't buy
Microsloth unless I have to) is this... I was at work making DOS
"menus" for some new machines that we got in, and I wanted to make them
display ANSI menus if ANSI.SYS was loaded, or regular menus (ASCII) if
not... I thought about this forever, and finally, as much as I could
come up with was this: But I didn't have an FSIZE utility, so I whipped
out my trusty copy of TPC along with TURBO.TPL (taking up a grand total
of about 110k) and wrote a little utility to fix it :) <-- just shows
that TPC and .TPL are all you need sometimes...
mem/c|find /i "ANSI">$menu$.tmp fsize $menu$.tmp 1
if errorlevel.........
So that if the size of the file $menu$.tmp was equal to or greater than
1, FSIZE would return errorlevel 2, otherwise errorlevel 1. Can anyone
think of a way to do this in DOS strictly? Kind of off-topic, but I did
write a whole 2-minute program :)}
program fsize;
uses dos;
var
f : file;
s,fname : string;
code : integer;
actualsize,ssize : longint;
procedure writehelp;
begin
writeln('FSize utility, Copyright 1993 Alphawave Technologies');
writeln('usage:');
writeln(' FSize filename [minsize]');
writeln('Where filename is the file to check the filesize of.');
writeln('If minsize is omitted, it is assumed to be 1. Filesize will');
writeln('return an errorlevel of 2 if the file is the size of minsize or');
writeln('greater, an errorlevel of 1 if the file size is smaller than');
writeln('minsize, and an errorlevel of 0 if this help screen appears.');
halt(0);
end; { writehelp }
begin
if paramcount = 0 then
writehelp
else
fname := paramstr(1);
assign(f,fname);
{$i-} reset(f); {$I+}
if ioresult <> 0 then
writehelp;
if paramcount = 1 then
ssize := 1
else
begin
s := paramstr(2);
val(s,ssize,code);
if code <> 0 then ssize := 1;
end; { else }
{ If the filesize of F is greater than or equal to the filesize specified
on the command line, halt with an errorlevel of 2, otherwise an error-
level of 1 }
actualsize := filesize(f);
close(f);
if actualsize >= ssize then halt(2) else halt(1);
end. { fsize }